#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a;i<n;++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int getSi[1000100];
int arr[1000100];
char s[1010];
class SuffixArray
{
  public:
  int *sa,*rank;
  int *height;
  int keyTypeMax,length;
  SuffixArray(int *a,int n,int m)
  {
    keyTypeMax = max(m,n)+5;
    sa = new int[n+10];
    rank = new int[keyTypeMax];
    height = new int[n+10];
    length = n+1;
    a[n]=0;
    setSa(a);
    setHeight(a);
  }
  ~SuffixArray()
  {
    delete(sa);
    delete(rank);
    delete(height);
  }
  void setSa(int *a)
  {
    int *cnt = new int[keyTypeMax];
    REP(i,keyTypeMax) cnt[i] = 0;
    REP(i,length) cnt[rank[i]=a[i]]++;
    REP(i,keyTypeMax-1) cnt[i+1]+=cnt[i];
    for(int i=length-1;i>=0;--i) sa[--cnt[rank[i]]] = i;

    int *rankSt = new int[keyTypeMax];
    int *rankStPos = new int[length+10];
    for(int p=0,h=1,rankMax=keyTypeMax;
        p<length;h<<=1,rankMax=p)
    {
        p = 0;
        FOR(i,length-h,length) rankStPos[p++]=i;
        REP(i,length) if(sa[i]>=h) rankStPos[p++] = sa[i]-h;
        REP(i,length) rankSt[i]= rank[rankStPos[i]];
        REP(i,rankMax) cnt[i] =0;
        REP(i,length) cnt[rankSt[i]]++;
        REP(i,rankMax-1) cnt[i+1]+=cnt[i];
        for(int i = length-1;i>=0;i--) sa[--cnt[rankSt[i]]]=rankStPos[i];

        swap(rank,rankStPos);
        rank[sa[0]] = 0;
        p=1;
        FOR(i,1,length)
        {
            if(rankStPos[sa[i]]==rankStPos[sa[i-1]]
               &&rankStPos[sa[i]+h]==rankStPos[sa[i-1]+h])
               rank[sa[i]] = p-1;
               else rank[sa[i]] = p++;
        }
    }
    delete(rankStPos);
    delete(rankSt);
    delete(cnt);
  }
  void setHeight(int *a)
  {
    int h = 0;
    REP(i,length)
    {
        int  r = rank[i];
        if(!r) height[r] = h =0;
        else
        {
            int pb = sa[r-1];
            int off=(h?h-1:0);
            while(a[i+off]==a[pb+off])off++;
            height[r] = h =off;
        }
    }
    //REP(i,length) printf("height[%d] = %d\n",i,height[i]);
  }
  bool check(int len,int n)
  {
    int done[110];
    fill(done,done+n,-1);
    int cnt = 1;
    int gp=0;
    REP(i,length)
    {
        int si = getSi[sa[i]];
        if(height[i]>=len)
        {
            if(done[si]!=gp) done[si] = gp,cnt++;
            if(cnt>n/2) return true;
        }
        else
        {
            gp++;
            done[si] = gp;
            cnt = 1;
        }
    }
    return false;
  }
  void getAns(int n)
  {
    int low = 0,high = length;
    while(low<=high)
    {
        int len = (low+high)>>1;
        if(check(len,n)) low = len+1;
        else high = len-1;
    }
    printAns(high,n);
  }
  void printAns(int len,int n)
  {
    if(len==0)
    {
        puts("?\n");
        return;
    }
    int done[110];
    fill(done,done+n,-1);
    int cnt = 1;
    int gp=0;
    bool canPrint = true;
    REP(i,length)
    {
        int si = getSi[sa[i]];
        if(height[i]>=len)
        {
            if(done[si]!=gp) done[si] = gp,cnt++;
            if(cnt>n/2&&canPrint)
            {
                for(int j=0;j<len;j++)
                {
                    char c =  arr[sa[i]+j] - 110;
                    putchar(c);
                }
                cout<<endl;
                canPrint =false;
            }
        }
        else
        {
            gp++;
            done[si] = gp;
            cnt = 1;
            canPrint = true;
        }
    }
    cout<<endl;
  }
};

int main()
{
    int n;
    int pi;
    while(cin>>n)
    {
        if(!n) break;
        pi=0;
        REP(i,n)
        {
            scanf("%s",s);
            for(char *sp=s;*sp;sp++)
            {
                getSi[pi] = i;
                arr[pi++] = (*sp)+110;
            }
            arr[pi++] = n-i;
        }
        SuffixArray sa(arr,pi,300);
        sa.getAns(n);
    }
	return 0;
}
